home *** CD-ROM | disk | FTP | other *** search
/ Amiga Tools 5 / Amiga Tools 5.iso / tools / developer-tools / andere sprachen / gamesmaster / demosrc / doublebuffer.s < prev    next >
Encoding:
Text File  |  1996-07-16  |  3.7 KB  |  130 lines

  1. ;Double Buffering
  2. ;----------------
  3. ;This just shows how to double buffer the screen.  You can also try out
  4. ;triple buffering just by changing the DBLBUFFER flag to TPLBUFFER in the
  5. ;ScreenStruct.
  6. ;
  7. ;Notice that this thing does in fact fully multi-task (no forbid/permit)!
  8. ;Instead we set our task priority to be a little higher than any other tasks
  9. ;-- if we didn't do this sometimes our frames could be stalled (try removing
  10. ;the SetUserPri and watch the demo again).
  11.  
  12.     opt    o+
  13.  
  14.     INCLUDE    "exec/exec_lib.i"
  15.     INCLUDE    "games/games_lib.i"
  16.     INCLUDE    "games/games.i
  17.  
  18. CALL    MACRO
  19.     jsr    _LVO\1(a6)
  20.     ENDM
  21.  
  22. LOCAL    =    0
  23.  
  24.     SECTION    "Double_Buffer",CODE
  25.  
  26. ;===========================================================================;
  27. ;                             INITIALISE DEMO
  28. ;===========================================================================;
  29.  
  30. Start:    MOVEM.L    A0-A6/D1-D7,-(SP)
  31.     move.l    ($4).w,a6
  32.     lea    GMS_Name(pc),a1
  33.     moveq    #$00,d0
  34.     CALL    OpenLibrary
  35.     move.l    d0,GMS_Base
  36.     beq.s    Quit
  37.  
  38.     move.l    GMS_Base(pc),a6          ;Set the task priority to a
  39.     CALL    SetUserPri               ;user-selected level.
  40.  
  41.     lea    ScreenStruct(pc),a0      ;Add screen for use.
  42.     CALL    Add_Screen
  43.     tst.l    d0
  44.     bne.s    Error
  45.  
  46.     move.l    SS_MemPtr1(a0),a1        ;Destination = SS_MemPtr1.
  47.     lea    PackedPicFile(pc),a0     ;File Name.
  48.     CALL    QuickLoad
  49.     tst.l    d0
  50.     beq.s    Error
  51.  
  52.     lea    ScreenStruct(pc),a0      ;Unpack the data on top of itself.
  53.     move.l    SS_MemPtr1(a0),a1
  54.     move.l    a1,a0
  55.     moveq    #$00,d0
  56.     CALL    SmartUnpack
  57.  
  58.     lea    ScreenStruct(pc),a0      ;Now show the screen/pic.
  59.     CALL    Show_Screen
  60.  
  61. ;===========================================================================;
  62. ;                                MAIN LOOP
  63. ;===========================================================================;
  64.  
  65. Loop:    CALL    Wait_OSVBL               ;Nice VBL wait for multi-tasking.
  66.     CALL    SwapBuffers
  67.     moveq    #JPORT1,d0               ;Port 1 (mouse)
  68.     moveq    #JT_SWITCH,d1
  69.     CALL    Read_JoyPort
  70.     btst    #JS_FIRE1,d0
  71.     beq.s    Loop
  72.  
  73. ;===========================================================================;
  74. ;                              RETURN TO DOS
  75. ;===========================================================================;
  76.  
  77.     CALL    Delete_Screen            ;Give back screen memory etc.
  78.  
  79. Error    move.l    GMS_Base(pc),a1
  80.     move.l    ($4).w,a6
  81.     CALL    CloseLibrary
  82. Quit    MOVEM.L    (SP)+,A0-A6/D1-D7
  83.     moveq    #$00,d0
  84.     rts
  85.  
  86. ;===========================================================================;
  87. ;                                  DATA
  88. ;===========================================================================;
  89.  
  90. GMS_Name:
  91.     dc.b    "games.library",0
  92.     even
  93. GMS_Base:
  94.     dc.l    0
  95.  
  96. AMT_PLANES =    5
  97.  
  98. ScreenStruct:
  99.     dc.l    "GSV1"
  100.     dc.l    0,0,0                    ;Screen_Mem1/2/3
  101.     dc.l    0                        ;Screen link.
  102.     dc.l    ScreenPalette            ;Address of screen palette
  103.     dc.l    0                        ;Address of rasterlist.
  104.     dc.l    0                        ;Amt of colours in palette.
  105.     dc.w    256,320,320/8            ;Screen Height, Width, Width/8
  106.     dc.w    256,320,320/8            ;Pic Height, Width, Width/8
  107.     dc.w    AMT_PLANES               ;Amt_Planes
  108.     dc.w    0,0                      ;Hardware offset, X/Y
  109.     dc.w    0                        ;Scroll buffer in pixels/8.
  110.     dc.w    0,0                      ;X/Y counters (for scrolling).
  111.     dc.l    DBLBUFFER|NOBURST        ;Special attributes.
  112.     dc.w    LORES                    ;Screen mode.
  113.     dc.b    INTERLEAVED              ;Screen type
  114.     dc.b    0                        ;Screen Is Being Displayed?
  115.     dc.l    0,0                      ;Reserved area.
  116.     even
  117.  
  118. ScreenPalette:
  119.     dc.w    $0000,$0A77,$0B88,$0866,$0A98,$0877,$0B99,$0CBB
  120.     dc.w    $0ABB,$0CCC,$0333,$0554,$0556,$0665,$0788,$0222
  121.     dc.w    $0466,$0345,$0677,$0888,$0234,$0322,$0844,$0733
  122.     dc.w    $0632,$0955,$09AA,$0022,$0832,$0943,$0DCC,$0DDD
  123.  
  124. PackedPicFile:
  125.     IFNE    LOCAL
  126.     dc.b    "GAMESLIB:"
  127.     ENDC
  128.     dc.b    "data/Pic320.pak",0
  129.     even
  130.